import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import { resolve } from 'path';
import uniAxiosAdapter from '@uni-helper/axios-adapter/vite'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  return {
    base: './',
    plugins: [
      uni(),
      uniAxiosAdapter()
    ],
    resolve: {
      alias: {
        "@": resolve(__dirname, "src"),
      }
    },
    server: {
      // 允许IP访问
      host: '0.0.0.0',
      // 应用端口 (默认:3000)
      port: 3333,
      // 运行是否自动打开浏览器
      open: true,
      proxy: {
        '/api': {
          changeOrigin: true,
          target: 'http://hn.api.yesapi.net/api', // 接口基础地址
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    },
  }
})